import { loadEnv } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import path from 'path';
// import viteCompression from 'vite-plugin-compression';
import uniReadPagesV3Plugin from './LC/router/utils/uni-read-pages-v3';
import requireTransform from 'vite-plugin-require-transform';
import postcss from 'postcss-100vh-fix';
// https://vitejs.dev/config/
export default (command, mode) => {
  const env = loadEnv(mode, __dirname, 'SHOPRO_');
  return {
    envPrefix: 'LC_',
    plugins: [
      uni(),
      // viteCompression({
      // 	verbose: false
      // }),
	  postcss(),
	   requireTransform({
	        fileRegex: /.js$|.vue$/
	      }),

      uniReadPagesV3Plugin({
        pagesJsonDir: path.resolve(__dirname, './pages.json'),
        includes: ['path', 'aliasPath', 'name', 'meta'],
      }),
      
    ],
      build: {
        commonjsOptions: {
          transformMixedEsModules: true,
        },
      },
	server: {
      host: true,
      // open: true,
      port: env.SHOPRO_DEV_PORT,
      hmr: {
        overlay: true,
      },
    },
  };
};
